package wang;

class Dog{
    public String name;
    public String color;
    public int age;
    public void eat(){
        System.out.println(name + "正在吃狗粮");
    }
}
class Cat extends Dog{
    public int a;
    int b;
    int c;
    {
        this.name = "小狗";
    }
    {
        this.a = 10;
        this.b = 20;
        this.c = 30;
    }
    public void eat(){
        System.out.println(name + "正在吃");
    }
    public void print(){
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
    }
    public void print2(){
        super.age = 11;
        System.out.println(super.age);
    }
    public void print3(){
        //要想实现多态必需要满足以下三点：向上转型，子类必须要对父类中的方法进行重写，通过父类引用来调用这个子类对象的重重写方法
        Dog dog = new Cat();
        dog.eat();
    }
    
}
public class Text {
    public static void main(String[] args) {

        Cat cat = new Cat();
        cat.print();
        cat.print2();
        cat.print3();
//        Dog dog = new Cat();
//        dog.eat();
    }
}
